package repository

import (
	"fmt"
	"net/http"
	libs "sg/libs"
	models "sg/models"

	"github.com/gin-gonic/gin"
)

func UserList(c *gin.Context) {
	user := make([]models.User, 0)
	err := libs.Engine.Table("user").Find(&user)
	fmt.Println(user)
	if err != nil {
		fmt.Println(err)
		c.JSON(http.StatusBadRequest, gin.H{"error": "01> " + err.Error()})
	} else {
		c.JSON(http.StatusOK, user)
	}

}
